/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package howework.demo04;

/**
 *
 * @author Administrator
 */
public class CheckID {
    public static void main(String[] args) {
        String mobile="452126199006210633";
        boolean flag=true;
        if(mobile.length()!=18){
            flag=false;
            if(!(mobile.startsWith("45")||mobile.startsWith("15"))){
                flag=false;
            }
            String numstr="0123456789x";
            for(int i=0;i< mobile.length();i++){
                char c=mobile.charAt(i);
                int temp=numstr.indexOf(c);
                if(temp<0){
                    flag=false;
                    break;
                }
            }
            if(flag){
                System.out.println("是合法的身份证号码");
                
            }
            else
            {
                System.out.println("不是合法的身份证号码");
            }    
        }
        
    }

}


}
